<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]-->
    <script type="text/javascript" src="../../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../../lib/respond.min.js?rev=@@hash"></script>
    <!--[endif]-->
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../../../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../../../ht-css/Project.css" />
    <link rel="stylesheet" type="text/css" href="../../../../ht-css/style-q.css" />
    <!--[if IE 6]-->
    <script type="text/javascript" src="../../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <!--[endif]-->
    <title>新増ios版本号</title>
</head>
<body>
<nav class="breadcrumb">移动端管理 <span class="c-gray en">&gt;</span> <span onclick="returnVer()" style="cursor: pointer">ios版本号管理</span><span class="c-gray en">&gt;</span> 新増<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px ;display:block" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
    <form class="ml-20 mr-20" id="appVersionForm"  method="post">
        <div class="bk-gray bg-1 pd-20 text-c">
            <table class="table mt-10 col-2-1" style="margin-left: 35%">
                <tbody>
                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-26"><em class="c-red mr-5">*</em>版本号：</label>
                            <input type="text" class="input-text radius f-l ml-10" id="versionCode" name="versionCode" style="width: 60%"  onkeyup = "value=value.replace(/[^\d]/g,'')" required>
                        </div>
                    </td>
                </tr>
                <tr id="content">
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-26"><em class="c-red mr-5">*</em>更新内容：</label>
                            <input type="text" class="input-text radius f-l ml-10" maxlength="20" name="content" style="width: 60%">
                            <a href="javascript:;" class="f-l ml-10"  style="color:#1476e5;" onclick="addUpdateContent()">增加</a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-26"><em class="c-red mr-5">*</em>压缩包名称：</label>
                            <input type="text" class="input-text radius f-l ml-10" id="fileName" name="fileName" style="width: 60%"   required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-26"><em class="c-red mr-5">*</em>下载路径：</label>
                            <input type="text" class="input-text radius f-l ml-10" id="filePath" name="filePath" style="width: 60%"   required>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-30" style="height:26px"><em class="c-red mr-5">*</em>是否强制：</label>
                            <span class="select-box size-M ml-10 f-l" style="width:40%">
                                    <select class="select" name="updateType" id="updateType">
                                        <option value="">请选择</option>
                                        <option value="20">强制更新</option>
                                        <option value="10">非强制更新</option>
                                    </select>
                                </span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-30" style="height:26px"><em class="c-red mr-5">*</em>状态：</label>
                            <span class="select-box size-M ml-10 f-l" style="width:40%">
                                    <select class="select" name="isOn" id="isOn">
                                        <option value="">请选择</option>
                                        <option value="20">开启</option>
                                        <option value="10">关闭</option>
                                    </select>
                                </span>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="text-c mt-10">
                <input type="button" class="btn btn-secondary radius size-S" value="确认" onclick="save()">
                <input type="button" class="btn radius size-S ml-10" value="取消" onclick="returnVer()">
            </div>
        </div>
    </form>

</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script src="../../../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script src="../../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../../../ht-js/Project.js?rev=@@hash"></script>
<script src="../../../../ht-js/operation-js/operation_activity/activity_login.js?rev=@@hash"></script>

<link type="text/css" rel="stylesheet" href="../../../../ht-js/operation-js/time-js/jedate.css">
<script type="text/javascript" src="../../../../ht-js/operation-js/time-js/jquery.jedate.js?rev=@@hash"></script>
<script>
    function returnVer(){
        layer.confirm('确认要取消吗？', {
            btn : [ '确定', '取消' ]//按钮
        }, function() {
           /* $("body").load("ios_version.html");*/
            window.parent.selectAppVersionByPage();
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
    }

    //添加更新内容
    function addUpdateContent() {

        var contentLength = $("input[name='content']").length;
        var contents = $("input[name='content']");
        if (contentLength<5){
            let contentStr = '<tr id="'+contentLength+'">'+
                '<td>'+
                '<div>'+
                '<label class="form-label f-l w-85 text-r lh-26" style="height:26px"></label>'+
                '<input type="text" class="input-text radius f-l ml-10" name="content" style="width: 60%" maxlength="20">'+
                '<a href="javascript:;" class="f-l ml-10"  style="color:#1476e5;" onclick="removeMe(this)">删除</a>'+
                '</div>'+
                '</td>'+
                '</tr>';

            $(contents[contentLength-1]).parent().parent().parent().after(contentStr);
        }else {
            layer.msg('内容最多添加5条哦！', {icon: 5,time:2000});
        }
    }

    //删除当前节点
    function removeMe(obj) {
        $(obj).parent().parent().parent().remove();
    }

    //提交当前版本信息
    function save(){

        let versionCode = $("#versionCode").val();
        if (null == versionCode || "" === versionCode){
            layer.msg('版本号不能为空！', {icon: 5,time:2000});
            return;
        }

        let fileName = $("#fileName").val();

        let filePath = $("#filePath").val();

        let appVersionApk = {
            "fileName": fileName,
            "filePath": filePath
        }

        let contentArr = [];
        let contents = $("input[name='content']");
        for (let i=0;i<contents.length;i++) {
            let con = {"content":contents[i].value}
            if (null == contents[i].value || "" === contents[i].value){
                layer.msg('更新内容不能为空！', {icon: 5,time:2000});
                return;
            }
            contentArr.push(con)
        }

        let updateType = $("#updateType option:selected").val();
        if (null == updateType || "" === updateType){
            layer.msg('必须填写是否强制更新！', {icon: 5,time:2000});
            return;
        }

        let isOn = $("#isOn option:selected").val();
        if (null == isOn || "" === isOn){
            layer.msg('必须填写开启状态！', {icon: 5,time:2000});
            return;
        }
        let updateUser = JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name;

        $.ajax({
            /*root.appversions.insertVersionInfo*/
            url: 'https://'+ window.location.host +'/api/admin/abaseservice/version/insertVersionInfo',
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            contentType: "application/json",
            data: JSON.stringify({
                "type": "20",
                "versionCode": versionCode,
                "appVersionApk": appVersionApk,
                "updateType": updateType,
                "isOn": isOn,
                "appVersionContentList":contentArr,
                "updateUser": updateUser
            }),
            success: function(data){
                if (data.sub_code == 0){
                    /*layer.msg(data.sub_msg, {icon: 1,time:2000});
                    $("body").load("ios_version.html");*/
                    layer.msg(data.sub_msg,{icon: 1,time:2000},function () {
                        setTimeout(function () {
                            window.parent.selectAppVersionByPage();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        })
                    });

                }else {
                    layer.msg(data.sub_msg, {icon: 5,time:2000});
                }
                console.log(data)
                // /$("body").load("ios_version.html");
            },
            error:function(data){
                alert("error"+data);
            }
        });
    }
</script>
</body>
</html>